package com.example.mobile2030606174mzq0506;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private EditText Edit_one;
private Button But_one,But_two,But_there,But_four;

private String input;
private Uri uri;
private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
     inOck();
    }




    private void inOck(){

        Edit_one = findViewById(R.id.Edit_one);
        But_one = findViewById(R.id.But_one);
        But_two = findViewById(R.id.But_two);
        But_there = findViewById(R.id.But_there);
        But_four = findViewById(R.id.But_four);



        But_one.setOnClickListener(this);
        But_two.setOnClickListener(this);
        But_there.setOnClickListener(this);
        But_four.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.But_one:
                input = Edit_one.getText().toString().trim();
                uri = Uri.parse(input);
                intent = new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);
                break;
            case R.id.But_two:
                input = Edit_one.getText().toString().trim();
                uri = Uri.parse("tel:"+input);
                intent = new Intent(Intent.ACTION_DIAL,uri);
                startActivity(intent);
                break;

            case R.id.But_there:
                input = Edit_one.getText().toString().trim();
                uri = Uri.parse("geo"+input);
                intent = new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);
                break;
            case R.id.But_four:
                intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivity(intent);
                break;
        }

    }
}